package com.goldfish666.remote_control.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@Component
public class StringListConverter {

    public String listToString(List<Byte> byteList) {
        StringBuilder stringBuilder = new StringBuilder();
        for (Byte aByte : byteList) {
            stringBuilder.append(aByte.toString());
        }
        return stringBuilder.toString();
    }

    public List<Byte> stringToList(String str) {
        List<Byte> result = new ArrayList<>();
        for (int i = 0; i < str.length(); i++) {
            result.add(Byte.valueOf(String.valueOf(str.charAt(i))));
        }
        return result;
    }
}
